
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Collectors;

public class StringExtractor {

    enum State {
        NORMAL,
        STRING,
        ESCAPE
    }

    private State currentState;
    private StringBuilder currentString;
    private StringBuilder result;

    public StringExtractor() {
        this.currentState = State.NORMAL;
        this.currentString = new StringBuilder();
        this.result = new StringBuilder();
    }

    public void handleChar(char c) {
        switch (currentState) {
            case NORMAL:
                if (c == '"') {
                    currentState = State.STRING;
                    currentString.setLength(0); // Reset current string
                } // Ignore other characters in NORMAL state
                break;
            case STRING:
                if (c == '\\') {
                    currentState = State.ESCAPE;
                } else if (c == '"') {
                    currentState = State.NORMAL;
                    result.append(currentString.toString());
                    result.append('"'); // Append the closing quote
                } else {
                    currentString.append(c);
                }
                break;
            case ESCAPE:
                currentString.append(c);
                currentState = State.STRING;
                break;
        }
    }

    public String getResult() {
        return result.toString();
    }

    public static void main(String[] args) throws IOException {
        StringExtractor extractor = new StringExtractor();

        String content = new String(Files.readAllBytes(Paths.get("source_code.txt")));
        for (char c : content.toCharArray()) {
            extractor.handleChar(c);
        }

        System.out.println(extractor.getResult());
    }

}
